loginApp.config(function($stateProvider) {
  $stateProvider.state('login', {
    url: '/',
    name: 'login',
    templateUrl: '/login/partail/login.html',
    controller: function($scope, loginApiActions, token, sha) {
      var service = loginApiActions.list;
      var name = window.localStorage.getItem('phoneNo');
      var word = window.localStorage.getItem('passWord');
      if (name && word) {
        $scope.formData = {};
        $scope.formData.phoneNo = name;
        $scope.formData.passWord = word;
      }

      var methods = {
        signInSave: function(formData) {
          /*if (checked === true) {
            console.log(formData)
            window.localStorage.setItem('account', formData.phoneNo);
            window.localStorage.setItem('pwd', formData.passWord);
          }*/
        //  formData.pwd = sha(formData.passWord)
        	formData.v = '1.0';
          console.log(formData)
          service.signIn(formData)
            .then(
              function(res) {
                console.log("res="+res.data)
                if (res.data.msg == '成功.') {
                  window.localStorage.setItem('token', res.data.data.token);
                  window.localStorage.setItem('realName', res.data.data.realName);
                  console.log(res.data.data.token);
                  window.location.href = 'http://localhost:8900/#/survey';
                } else {
                  alert(res.data.message)
                }
              }
            );
        },
      }
      angular.extend($scope, methods);
    }
  })
})
